
\chapter{Lists}





This section describes routines available for creating, examining,
and otherwise manipulating list structure.


\section{Predicates}



\index{NULL?@{\tt NULL?}}
{\mbox {\tt (NULL? {\it object\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill Type predicate

\begin{inset}{}
Returns true if {\it object\/} is the empty list (null).  Since the empty
list is also used for the logical false value, and non-false objects are
considered to be true, it turns out that {\tt NULL?} is the same as {\tt NOT}.
\end{inset} 

\index{PAIR?@{\tt PAIR?}}
{\mbox {\tt (PAIR? {\it object\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill Type predicate

\begin{inset}{}
Returns true if {\it object\/} is a pair.
\begin{codexenv}
    \begin{tabular}{lll}
(PAIR? '(A B C))   &$\Longrightarrow$\ &  {\it true} \\
(PAIR? '(A . 15))  &$\Longrightarrow$\ &  {\it true} \\
(PAIR? '())        &$\Longrightarrow$\ &  {\it false} \\
(PAIR? 'FOO)       &$\Longrightarrow$\ &  {\it false}
\end{tabular}
    \end{codexenv}
\end{inset} 


\index{ATOM?@{\tt ATOM?}}
{\mbox {\tt (ATOM? {\it object\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill Type predicate

\begin{inset}{}
Returns true if {\it object\/} is an atom.
An atom is any object that isn't a pair.
\begin{codexenv}
(ATOM? {\it object\/})  $\equiv$  (NOT (PAIR? {\it object\/}))
\end{codexenv}
\end{inset} 


\index{LIST?@{\tt LIST?}}
{\mbox {\tt (LIST? {\it object\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill Type predicate

\begin{inset}{}
Returns true if {\it object\/} is either a pair or the empty list.
\begin{codexenv}
    \begin{tabular}{lll}
(LIST? '(A B C))   &$\Longrightarrow$\ &  {\it true} \\
(LIST? '(A . 15))  &$\Longrightarrow$\ &  {\it true} \\
(LIST? '())        &$\Longrightarrow$\ &  {\it true} \\
(LIST? 'FOO)       &$\Longrightarrow$\ &  {\it false}
\end{tabular}
    \end{codexenv}
\end{inset} 


\index{PROPER-LIST?@{\tt PROPER-LIST?}}
{\mbox {\tt (PROPER-LIST? {\it object\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill Type predicate

\begin{inset}{}
Returns true if {\it list\/} is a properly formed list, i.e., if its last
pair's cdr is null.
\begin{codexenv}
    \begin{tabular}{lll}
(PROPER-LIST? '(A B C))    &$\Longrightarrow$\ &  {\it true} \\
(PROPER-LIST? '(A B . C))  &$\Longrightarrow$\ &  {\it false} \\
(PROPER-LIST? '())         &$\Longrightarrow$\ &  {\it true}
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{NULL-LIST?@{\tt NULL-LIST?}}
{\mbox {\tt (NULL-LIST? {\it list\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill  

\begin{inset}{}
Like {\tt NULL?}, but has an undefined effect (and may, for example,
signal an error) if its argument is not either a pair or null.
{\mbox {\tt (NULL-LIST? {\it x\/})}} is roughly the same as
{\mbox {\tt (NULL? (ENFORCE LIST? {\it x\/}))}}.
\end{inset} 

\section{Constructors}


\index{CONS@{\tt CONS}}
{\mbox {\tt (CONS {\it object1 object2\/}) $\longrightarrow$\  {\it pair\/}}}
\hfill  

\begin{inset}{}
Returns a new pair whose car is {\it object1\/} and whose cdr is {\it object2\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(CONS 'A '())            &$\Longrightarrow$\ &  (A) \\
(CONS 'A 'B)             &$\Longrightarrow$\ &  (A . B) \\
(CONS 'A '(B))           &$\Longrightarrow$\ &  (A B) \\
(CONS 'A (CONS 'B '()))  &$\Longrightarrow$\ &  (A B) \\
(CONS 'A (LIST 'B 'C))   &$\Longrightarrow$\ &  (A B C)
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{LIST@{\tt LIST}}
{\mbox {\tt (LIST . {\it objects\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Returns a new list of its arguments.
\begin{codexenv}
    \begin{tabular}{lll}
(LIST)                  &$\Longrightarrow$\ &  () \\
(LIST 'A)               &$\Longrightarrow$\ &  (A) \\
(LIST 'A 'B)            &$\Longrightarrow$\ &  (A B) \\
(LIST 'A (LIST 'B 'C))  &$\Longrightarrow$\ &  (A (B C)) \\
LIST  &$\equiv$&  (LAMBDA THINGS THINGS)
\end{tabular}
    \end{codexenv}
\end{inset} 


\index{CONS*@{\tt CONS*}}
{\mbox {\tt (CONS* . {\it objects\/}) $\longrightarrow$\  {\it pair\/}}}
\hfill  

\begin{inset}{}
{\tt CONS*} is a generalized {\tt CONS}.
It returns a new, possibly improper, list,
by consing the initial {\it objects\/} onto the last {\it object\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(CONS* 1 2 3)          &$\Longrightarrow$\ &  (1 2 . 3) \\
(CONS* 'A 'B '(C D))  &$\Longrightarrow$\ &  (A B C D) \\
(CONS* {\it object\/})   &$\equiv$&  {\it object\/} \\
(CONS* {\it object1 object2\/}) &$\equiv$&  (CONS {\it object1 object2\/})
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{COPY-LIST@{\tt COPY-LIST}}
{\mbox {\tt (COPY-LIST {\it list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Makes a ``top-level'' copy of a list; that is, returns a new
list whose elements are the same as the original.
{\tt \begin{tabbing}
(COPY-LIST \= {\it list\/})  $\equiv$ \+ \\
  (COND \= ((NULL-LIST? {\it list\/}) '()) \\
        \> (ELSE (CONS (CAR {\it list\/}) (COPY-LIST (CDR {\it list\/}))))) \- \\

(COPY-LIST {\it list\/})  $\equiv$  (MAP IDENTITY {\it list\/}) \\
\end{tabbing}}
\end{inset} 

\section{List access}


\index{CAR@{\tt CAR}}
{\mbox {\tt (CAR {\it pair\/}) $\longrightarrow$\  {\it object\/}}}
\hfill Settable

\begin{inset}{}
Returns the car of the {\it pair\/}.
{\mbox {\tt (CAR () $\longrightarrow$\  {\it error})}}',
though, for compatibility, in {\bf T3.1} it will evaluate to {\mbox {\tt ()}}.
\end{inset} 

\index{CDR@{\tt CDR}}
{\mbox {\tt (CDR {\it pair\/}) $\longrightarrow$\  {\it object\/}}}
\hfill Settable

\begin{inset}{}
Returns the cdr of the {\it pair\/}.
{\mbox {\tt (CDR () $\longrightarrow$\  {\it error})}}',
though, for compatibility, in {\bf T3.1} it will evaluate to {\mbox {\tt ()}}.
\end{inset} 

\index{C...R@{\tt C...R}}
{\mbox {\tt (C...R {\it pair\/}) $\longrightarrow$\  {\it object\/}}}
\hfill Settable

\begin{inset}{}
Compositions of {\tt CAR} and {\tt CDR}, up to four deep, are defined.
\begin{codexenv}
    \begin{tabular}{lll}
(CADAR {\it x\/})   &$\equiv$&  (CAR (CDR (CAR {\it x\/}))) \\
(CADDDR {\it x\/})  &$\equiv$&  (CAR (CDR (CDR (CDR {\it x\/}))))
\end{tabular}
    \end{codexenv}
\end{inset} 


\index{NTH@{\tt NTH}}
{\mbox {\tt (NTH {\it list n\/}) $\longrightarrow$\  {\it object\/}}}
\hfill Settable

\begin{inset}{}
Returns the {\it nth\/} element of {\it list\/}.  The first element (the car) is
{\mbox {\tt (NTH {\it list\/} 0)}}, the second element is {\mbox {\tt (NTH {\it list\/} 1)}},
and so on.  In general, {\it list\/} must have at least {\it n\/}+1 elements.
\begin{codexenv}
    \begin{tabular}{lll}
(NTH '(A B) 0)  &$\Longrightarrow$\ &  A \\
(NTH '(A B) 1)  &$\Longrightarrow$\ &  B \\
(NTH '(A B) 2)   &&{\rm has an undefined effect} \\
(NTH '() {\it n\/}) &&{\rm has an undefined effect for any {\it n\/}}
\end{tabular}
    \end{codexenv}
\end{inset} 


\index{NTHCDR@{\tt NTHCDR}}
{\mbox {\tt (NTHCDR {\it list n\/}) $\longrightarrow$\  {\it list\/}}}
\hfill Settable

\begin{inset}{}
Returns the {\it nth\/} tail of {\it list\/}.  In general, {\it list\/}
must have at least {\it n\/} tails.
\begin{codexenv}
    \begin{tabular}{lll}
(NTHCDR '(A B) 0)  &$\Longrightarrow$\ &  (A B) \\
(NTHCDR '(A B) 1)  &$\Longrightarrow$\ &  (B) \\
(NTHCDR '(A B) 2)  &$\Longrightarrow$\ &  () \\
(NTHCDR '(A B) 3)   &&{\rm has an undefined effect} \\
(NTHCDR '() {\it n\/}) &&{\rm has an undefined effect for any nonzero {\it n\/}}
\end{tabular}
    \end{codexenv}
    \begin{inset}{Bug:}
    {\tt NTHCDR} doesn't handle {\tt SETTER} (i.e. is not settable) in
    {\bf T} 3.1.
    \end{inset}
\end{inset} 


\index{LAST@{\tt LAST}}
{\mbox {\tt (LAST {\it list\/}) $\longrightarrow$\  {\it object\/}}}
\hfill Settable

\begin{inset}{}
Returns the last element of {\it list\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(LAST '(A B C))  &$\Longrightarrow$\ &  C \\
(LAST {\it list\/})  &$\equiv$&  (CAR (LASTCDR {\it list\/}))
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{LASTCDR@{\tt LASTCDR}}
{\mbox {\tt (LASTCDR {\it list\/}) $\longrightarrow$\  {\it pair\/}}}
\hfill Settable

\begin{inset}{}
Returns the last pair in {\it list\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(LASTCDR '(A B C))    &$\Longrightarrow$\ &  (C) \\
(LASTCDR '(A B . C))  &$\Longrightarrow$\ &  (B . C)
\end{tabular}
    \end{codexenv}
    \begin{inset}{Bug:}
    {\tt LASTCDR} doesn't handle {\tt SETTER} (i.e. is not settable) in
    {\bf T} 3.1.
    \end{inset}
\end{inset} 

\section{Lists as sequences}


\index{LENGTH@{\tt LENGTH}}
{\mbox {\tt (LENGTH {\it list\/}) $\longrightarrow$\  {\it integer\/}}}
\hfill  

\begin{inset}{}
Return the length of {\it list\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(LENGTH '())       &$\Longrightarrow$\ &  0 \\
(LENGTH '(A B C))  &$\Longrightarrow$\ &  3
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{APPEND@{\tt APPEND}}
{\mbox {\tt (APPEND . {\it lists\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Constructs a list which is the concatenation of {\it lists\/}.
A new list is constructed, except that the result has
the last non-null argument as a tail.
\begin{codexenv}
(APPEND '(A B C) '(D E) '(F G))  $\Longrightarrow$\   (A B C D E F G)
\end{codexenv}
\end{inset} 


\index{APPEND!@{\tt APPEND!}}
{\mbox {\tt (APPEND! . {\it lists\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Destructive version of {\tt APPEND}.  Splices the lists together,
setting the cdr of the last pair in the first list to
the second list, and so on.  Returns its first non-null argument.
\begin{codexenv}
    \begin{tabular}{lll}
(DEFINE L1 (LIST 'A 'B 'C)) \\
(DEFINE L2 (LIST 'D 'E)) \\
L1                &$\Longrightarrow$\ &  (A B C) \\
(APPEND! L1 L2)   &$\Longrightarrow$\ &  (A B C D E) \\
L1                &$\Longrightarrow$\ &  (A B C D E) \\
(APPEND! '() L2)  &$\Longrightarrow$\ &  (D E)
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{REVERSE@{\tt REVERSE}}
{\mbox {\tt (REVERSE {\it list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Returns a new list whose elements are those of {\it list\/}, in reverse order.
\begin{codexenv}
(REVERSE '(A B C))  $\Longrightarrow$\   (C B A)
\end{codexenv}
\end{inset} 


\index{REVERSE!@{\tt REVERSE!}}
{\mbox {\tt (REVERSE! {\it list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
This is a ``destructive'' version of {\tt REVERSE};
it allocates no storage for the result, but rather recycles
the pairs in the source {\it list\/}'s to form the result list.
\index{destructive}
\end{inset} 

\index{SUBLIST@{\tt SUBLIST}}
{\mbox {\tt (SUBLIST {\it list\/} {\it start\/} {\it count\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Returns a list of {\it count\/} elements of {\it list\/},
beginning with element {\it start\/}.
\begin{codexenv}
(SUBLIST '(A B C D E F) 2 3)  $\Longrightarrow$\   (C D E)
\end{codexenv}
\end{inset} 

\section{Lists as sets}


\index{MEMQ?@{\tt MEMQ?}}
{\mbox {\tt (MEMQ? {\it object list\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill  

\begin{inset}{}
Returns true if {\it object\/} is an element of {\it list\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(MEMQ? 'B '(A B C))           &$\Longrightarrow$\ &  {\it true} \\
(MEMQ? 'B '(A (B C) D))       &$\Longrightarrow$\ &  {\it false} \\
(MEMQ? 'B '(B))               &$\Longrightarrow$\ &  {\it true} \\
(MEMQ? 'B '())                &$\Longrightarrow$\ &  {\it false} \\
(MEMQ? 17 '(10 17))           &$\Longrightarrow$\ &  {\rm undefined} \\
(MEMQ? foo '(foo bar))  &$\Longrightarrow$\ &  {\rm undefined} \\
(LET ((X foo)) \\
  (MEMQ? X (LIST 'B X)))      &$\Longrightarrow$\ &  {\it true}
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{MEM?@{\tt MEM?}}
{\mbox {\tt (MEM? {\it predicate object list\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill  

\begin{inset}{}
Returns true if {\it list\/} contains an object which
is equal to {\it object\/} according to {\it predicate\/},
which should be an equality predicate.
\begin{codexenv}
    \begin{tabular}{lll}
(MEM? = 17 '(10 17))                       &$\Longrightarrow$\ &  {\it true} \\
(MEM? STRING-EQUAL? foo '(foo bar))  &$\Longrightarrow$\ &  {\it true}
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{ANY?@{\tt ANY?}}
{\mbox {\tt (ANY? {\it predicate\/} . {\it lists\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill  

\begin{inset}{}
Returns true if any element of {\it list\/} answers true to {\it predicate\/}.
\begin{codexenv}
(ANY? NUMBER? '(FOO 15 BAR))  $\Longrightarrow$\   {\it true}
\end{codexenv}
\end{inset} 

\index{EVERY?@{\tt EVERY?}}
{\mbox {\tt (EVERY? {\it predicate\/} . {\it lists\/}) $\longrightarrow$\  {\it boolean\/}}}
\hfill  

\begin{inset}{}
Returns true if every element of {\it list\/} answers true to {\it predicate\/}.
\begin{codexenv}
(EVERY? SYMBOL? '(A B C))  $\Longrightarrow$\   {\it true}
\end{codexenv}
\end{inset} 

\index{DELQ@{\tt DELQ}}
{\mbox {\tt (DELQ {\it object list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Returns a list which is the same as the argument {\it list\/}
with all occurrences of {\it object\/} removed.
\end{inset} 

\index{DEL@{\tt DEL}}
{\mbox {\tt (DEL {\it predicate object list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Returns a list which is the same as {\it list\/} except that all
elements which, according to {\it predicate\/},
are equal to {\it object\/}, have been removed.
{\it Predicate\/} should be an equality predicate.
\begin{codexenv}
(DELQ {\it object list\/})  $\equiv$  (DEL EQ? {\it object list\/})
\end{codexenv}
\end{inset} 

\index{DELQ!@{\tt DELQ!}}
{\mbox {\tt (DELQ! {\it object list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Destructive version of {\tt DELQ}.
Removes all occurrences of {\it object\/} from {\it list\/},
possibly altering it, and returns the new and/or modified list.
\end{inset} 

\index{DEL!@{\tt DEL!}}
{\mbox {\tt (DEL! {\it predicate object list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
Destructive version of {\tt DEL}.
\begin{codexenv}
(DELQ! {\it object list\/})  $\equiv$  (DEL! EQ? {\it object list\/})
\end{codexenv}
\end{inset} 

\section{Mapping Procedures}


\index{MAP@{\tt MAP}}
{\mbox {\tt (MAP {\it proc\/} . {\it lists\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\label{MAP}
\begin{inset}{}
Returns a list of the results of applying {\it proc\/} to successive elements
of the {\it lists\/}; the {\it nth\/} element of the result list is the result
of calling {\it proc\/} on the {\it nth\/} elements of the {\it lists\/}.
The length of the result list is the same as the length of the shortest
of the {\it lists\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(MAP (LAMBDA (X) (LIST 'A X)) '(CAT DOG))  &$\Longrightarrow$\ &  ((A CAT) (A DOG)) \\
(MAP + '(10 20) '(5 6))                    &$\Longrightarrow$\ &  (15 26) \\
(MAP LIST '(A B) '(C D E) '(F))            &$\Longrightarrow$\ &  ((A C F))
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{MAPCDR@{\tt MAPCDR}}
{\mbox {\tt (MAPCDR {\it proc\/} . {\it lists\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
{\tt MAPCDR} is similar to {\tt MAP}, except that {\it proc\/} is applied to
successive {\it tails\/} of the {\it lists\/}.
\end{inset} 

\index{MAP!@{\tt MAP!}}
{\mbox {\tt (MAP! {\it proc\/} {\it list\/}) $\longrightarrow$\  {\it list\/}}}
\hfill  

\begin{inset}{}
For each pair in {\it list\/}, applies {\it proc\/} to the car of the pair,
and then modifies the pair so that its car is the value of the
application.
\begin{codexenv}
    \begin{tabular}{lll}
(DEFINE L (LIST 'CAT 'DOG))  &$\Longrightarrow$\ &  (CAT DOG) \\
(MAP! (LAMBDA (X) (LIST 'A X)) L) \\
L  &$\Longrightarrow$\ &  ((A CAT) (A DOG))
\end{tabular}
    \end{codexenv}
\end{inset} 

\index{WALK@{\tt WALK}}
{\mbox {\tt (WALK {\it proc\/} . {\it lists\/}) $\longrightarrow$\  {\it undefined\/}}}
\hfill  

\label{WALK}
\begin{inset}{}
This is similar to {\tt MAP} but the result is 
a value of no particular interest.
Thus {\tt WALK} is useful only for the side-effects that {\it proc\/} performs.
\end{inset} 

\index{WALKCDR@{\tt WALKCDR}}
{\mbox {\tt (WALKCDR {\it proc\/} . {\it lists\/}) $\longrightarrow$\  {\it undefined\/}}}
\hfill  

\begin{inset}{}
This is similar to {\tt MAPCDR} but the result is a value of no particular
interest.
\end{inset} 

\section{Lists as associations}


\index{ASSQ@{\tt ASSQ}}
{\mbox {\tt (ASSQ {\it object list\/}) $\longrightarrow$\  {\it pair\/} {\rm or} {\it false\/}}}
\hfill  

\begin{inset}{}
\begin{codexenv}
(ASSQ {\it object list\/})  $\equiv$  (ASS EQ? {\it object list\/})
\end{codexenv}
\end{inset} 

\index{ASS@{\tt ASS}}
{\mbox {\tt (ASS {\it predicate object list\/}) $\longrightarrow$\  {\it pair\/} {\rm or} {\it false\/}}}
\hfill  

\begin{inset}{}
An \iix{association list}
is a list of pairs that represents
a ``lookup table'' where the car of each pair matches a lookup key.  {\tt ASS}
and its related procedures search association lists by comparing
(applying {\it predicate\/}) the key ({\it object\/}) against the car of each
element of {\it list\/} (i.e., the caar of each tail).  If it finds a match,
it returns that element (the car of the tail).  If it finds no match,
it returns false.
\begin{codexenv}
    \begin{tabular}{lll}
(ASS EQ? 'B '((A 10 20) (B 30 40) (C 50 60)))  &$\Longrightarrow$\ &  (B 30 40) \\
(ASS = 9 '((1 Y) (4 Y) (9 Z) (12 P)))          &$\Longrightarrow$\ &  (9 Z) \\
(ASS = 10 '((1 Y) (4 Y) (9 Z) (12 P)))         &$\Longrightarrow$\ &  {\it false}
\end{tabular}
    \end{codexenv}
\end{inset} 

\section{Lists as stacks}


{\tt PUSH} and {\tt POP} permit a convenient syntax for the use of lists
in implementing simple stacks.  They are assignment forms, like {\tt SET}
and {\tt INCREMENT}.  See section \ref{section:assignment} for a general
discussion of assignment forms.

\index{PUSH@{\tt PUSH}}
{\mbox {\tt (PUSH {\it location object\/}) $\longrightarrow$\  {\it undefined\/}}}
\hfill Special form

\begin{inset}{}
Cons a pair whose car is {\it object\/} and whose cdr is
the value in {\it location\/} (usually a list), and
store the extended list back into {\it location\/}.
\begin{codexenv}
    \begin{tabular}{lll}
(LSET L '(34 55))  &$\Longrightarrow$\ &  (34 55) \\
(PUSH L 21) \\
L                  &$\Longrightarrow$\ &  (21 34 55) \\
(PUSH L '(A B C)) \\
(PUSH (CAR L) 'D) \\
L                  &$\Longrightarrow$\ &  ((D A B C) 21 34 55)
\end{tabular}
    \end{codexenv}

In general,
{\tt \begin{tabbing}
(PUSH \= {\it location object\/}) \+ \\
  $\equiv$  (SET {\it location\/} (CONS {\it object location\/})) \\
  $\equiv$  (MODIFY {\it location\/} (LAMBDA (L) (CONS {\it object\/} L))) \\
\end{tabbing}}
\end{inset} 

\index{POP@{\tt POP}}
{\mbox {\tt (POP {\it location\/}) $\longrightarrow$\  {\it object\/}}}
\hfill Special form

\begin{inset}{}
The car of the value in {\it location\/}
(this value should be a pair) is returned.  As a side-effect,
the cdr of the list is stored back in the location.
\begin{codexenv}
    \begin{tabular}{lll}
L        &$\Longrightarrow$\ &  (21 34 55) \\
(POP L)  &$\Longrightarrow$\ &  21 \\
L        &$\Longrightarrow$\ &  (34 55)
\end{tabular}
    \end{codexenv}
In general,
{\tt \begin{tabbing}
(POP \= {\it location\/})  $\equiv$   \+ \\
  (BLOCK0 (CAR {\it location\/}) \= (SET {\it location\/} (CDR {\it location\/}))) \\
                    \> $\equiv$   \\
  (BLOCK0 (CAR {\it location\/}) (MODIFY {\it location\/} CDR))
\end{tabbing}}
\end{inset} 
